import 'package:eplorex/providers/user_context.dart';
import 'package:flutter/material.dart';

import '../../../models/follow/userprofile_model.dart';
import '../user_profile_page.dart';

class UserAvatarModule extends StatefulWidget {
  const UserAvatarModule({super.key, required this.profileModel});

  final UserProfileModel profileModel;

  @override
  State<UserAvatarModule> createState() => _UserAvatarModuleState();
}

class _UserAvatarModuleState extends State<UserAvatarModule> {
  @override
  Widget build(BuildContext context) {
    return Container(
        // mainAxisAlignment: MainAxisAlignment.spaceBetween,
        child: Wrap(
      spacing: 5,
      crossAxisAlignment: WrapCrossAlignment.center,
      children: [
        GestureDetector(
          onTap: () => {
            if (widget.profileModel.userId == UserContext.cxt()!.uid)
              Navigator.pushReplacementNamed(context, '/my')
            else
              Navigator.of(context)
                  .push(MaterialPageRoute(
                      builder: (_) =>
                          UserProfilePage(userId: widget.profileModel.userId!)))
                  .then((value) => {
                        // setState(() {
                        //   _followStatus = !_needFresh;
                        // })
                      })
          },
          child: CircleAvatar(
            radius: 16,
            backgroundImage: NetworkImage(widget.profileModel.avatar!),
          ),
        ),
        Text(
          widget.profileModel.userName!,
          style: const TextStyle(fontSize: 16),
        )
      ],
    ));
  }
}
